{% extends 'mbase.html' %}
{% block title %}Coupon::Brispon{% endblock %}
{% block stylesheet %}
{{ block.super }}
{% endblock%}

{% block javascript %}
{{ block.super }}
<script>
$(function(){
    $("#sms").click(function(){
    var couponId = $(this).parent().attr("id");
    var address = 'sms/' + couponId; 
    var msg = '';
    //console.log(address);
    $.blockUI({ message: '<h3><img src="{% url base_static "images/loading.gif" %}"/> Sending Text Message...</h3>' }); 
    
    $.get(address, function(data){
      if(data.result == "sent") {
        msg = 'You will get the coupon in a few minutes  ';
      } else {
        msg = 'Fail to sent a coupon  ';
      }
    }).complete(function(){
      $.unblockUI();
      $.blockUI({message: '<h3>' + msg + '</h3>'});
      setTimeout($.unblockUI, 2000);
    });
    return false;
  });
});
</script>
{% endblock%}

{% block content %}
<div>
  <ul data-role="listview" data-inset="true" data-filter="true">
  {% for coupon in coupons %}
    <li><a href="#">{{ coupon.name }} </a></li>
  {% endfor %}
  </ul>
</div>
{% endblock %}
